package logic

import (
	"context"
	"errors"
	"fmt"
	"order_srv/models/mysql"

	"order_srv/internal/svc"
	"order_srv/order_srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type FindUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewFindUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindUserLogic {
	return &FindUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *FindUserLogic) FindUser(in *order_srv.FindUserRequest) (*order_srv.FindUserResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	err := user.FindStatus(int(in.UserId))
	if err != nil {
		fmt.Println("11111")
		return nil, err
	}
	if user.ID == 0 {
		fmt.Println("22222")
		return nil, errors.New("用户不存在")
	}
	return &order_srv.FindUserResponse{}, nil
}
